import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'models/hexagram.dart';
import 'screens/home_page.dart';
import 'screens/voice_divination_page.dart';
import 'screens/photo_divination_page.dart';
import 'screens/time_divination_page.dart';
import 'screens/number_divination_page.dart';
import 'screens/divination_result_page.dart';
import 'screens/hexagram_detail_page.dart';
import 'screens/share_poster_page.dart';
import 'screens/profile_page.dart';
import 'theme/app_theme.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  
  // 设置状态栏透明
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarIconBrightness: Brightness.dark,
    ),
  );
  
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '合一个',
      theme: AppTheme.lightTheme,
      initialRoute: '/',
      routes: {
        '/': (context) => const HomePage(),
        '/voice-divination': (context) => const VoiceDivinationPage(),
        '/photo-divination': (context) => const PhotoDivinationPage(),
        '/time-divination': (context) => const TimeDivinationPage(),
        '/number-divination': (context) => const NumberDivinationPage(),
        '/profile': (context) => const ProfilePage(),
      },
      onGenerateRoute: (settings) {
        if (settings.name == '/divination-result') {
          return MaterialPageRoute(
            builder: (context) => DivinationResultPage(
              arguments: settings.arguments as Map<String, dynamic>?,
            ),
          );
        }
        if (settings.name == '/hexagram-detail') {
          return MaterialPageRoute(
            builder: (context) => HexagramDetailPage(
              hexagram: settings.arguments as Hexagram,
            ),
          );
        }
        if (settings.name == '/share-poster') {
          return MaterialPageRoute(
            builder: (context) => SharePosterPage(
              hexagram: settings.arguments as Hexagram,
            ),
          );
        }
        return null;
      },
      debugShowCheckedModeBanner: false,
    );
  }
}